<template>
  <div id="app">
    <Header></Header>
    <router-view/>
    <!-- 部分路由不应该包含这个Footer -->
    <!-- <Footer v-if="excludeRoutes.indexOf($route.name) == -1"></Footer> -->
  </div>
</template>

<script>
import Header from '@/components/header/Header';
import Footer from '@/components/footer/Footer';
import { mapMutations, mapState } from 'vuex';

export default {
  name: 'App',
  data () {
    return {
      excludeRoutes: ['HomeIndex', 'MyAddress', 'AddAddress', 'MyOrder', 'MyShoppingCart', 'MyAddress1', 'AddAddress1', 'MyOrder1', 'MyShoppingCart1']
    };
  },
  methods: {
    ...mapMutations(['SET_USER_LOGIN_INFO'])
  },
  computed: {
    ...mapState(['userInfo'])
  },
  created () {
    var ms = 'color:rgb(30, 236, 92);font-size:20px;';
    if (window.console) console.log('%cThere is a long way to go .It’s OK to walk slowly\r\n', ms);
    const userInfoData = JSON.parse(localStorage.getItem('login-info'));
    if (userInfoData) {
      this.SET_USER_LOGIN_INFO(userInfoData);
    } else {
      this.$router.push('/');
    }
  },
  components: {
    Header,
    Footer
  }
};
</script>
